'''
Created on 2010-3-3

@author: Administrator
'''

from jolly.datastructures.Visitor import Visitor

class PrintingVisitor(Visitor):
    '''
    Visitor that prints the objects it visits.
    '''


    def __init__(self):
        '''
        (PrintingVisitor) -> None
        Constructor.
        '''
        super(PrintingVisitor, self).__init__()
        self._comma=False
    
    def visit(self, obj):
        '''
        (PrintingVisitor, Object)->None
        prints the object
        '''
        if self._comma:
            print ", ",
        print obj,
        self._comma = True
    
    def finish(self):
        '''
        (PrintingVisitor) -> None
        Finishes the line.
        '''
        print ""
        self._comma = False
        